//
//  Constants.h
//  OCBase
//
//  Created by 侯伟 on 2017/8/4.
//  Copyright © 2017年 侯伟. All rights reserved.
//

#ifndef Constants_h
#define Constants_h

#import "AppDelegate.h"

#pragma mark -- self

#define WeakSelf    __weak __typeof(self) weakSelf = self;

#define StrongSelf  __strong __typeof(weakSelf) strongSelf = weakSelf;


#pragma mark -- color

#define RGBCOLOR(r,g,b)         [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:1.0]

#define RGBACOLOR(r,g,b,a)      [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]

#define HEXCOLOR(rgbValue)      [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

#define HEXACOLOR(rgbaValue)    [UIColor colorWithRed:((float)((rgbaValue & 0xFF000000) >> 24))/255.0 green:((float)((rgbaValue & 0xFF0000) >> 16))/255.0 blue:((float)((rgbaValue & 0xFF00) >> 8))/255.0 alpha:((float)((rgbaValue & 0xFF) >> 0))/255.0]


//随机色
#define COLOR_RANDOM        RGBCOLOR(arc4random_uniform(255),arc4random_uniform(255),arc4random_uniform(255))


//主题红色
#define COLOR_THEME         COLOR_RED
//白色
#define COLOR_WHITE         HEXCOLOR(0xFFFFFF)

//深黑
#define COLOR_BLACK_DARK    HEXCOLOR(0x111A34)

//基础灰
#define COLOR_GRAY_BASE     HEXCOLOR(0x777878)

//很灰
#define COLOR_GRAY_QUITE    HEXCOLOR(0xB6B9C4)

//分割线灰色
#define COLOR_GRAY_LINE     HEXCOLOR(0xE8E8EE)

//背景色
#define COLOR_BACKGEOUND    HEXCOLOR(0xF1F2F3)

//红色
#define COLOR_RED           HEXCOLOR(0xFF6959)

//蓝色 高亮
#define COLOR_BLUE          HEXCOLOR(0x719DF0)


#define COLOR_THEME_A       COLOR_GREEN
//
//
////主题蓝 高亮
//#define COLOR_THEME_H       COLOR_BLUE_H
//
////浅黑
//#define COLOR_BLACK_DARK   HEXCOLOR(0x41485D)
////深灰
//#define COLOR_GRAY_DARK     HEXCOLOR(0x666F83)
//
////浅灰
//#define COLOR_GRAY_LIGHT    HEXCOLOR(0xCACAD5)
////很灰
//#define COLOR_GRAY_QUITE    HEXCOLOR(0xB6B9C4)
////分割线灰色
//#define COLOR_GRAY_LINE     HEXCOLOR(0xE8E8EE)
////按钮背景色
//#define COLOR_GRAY_BTNBACK  HEXCOLOR(0xF2F3F8)
//
////主体色背景
//#define COLOR_BACKGEOUND_THEM    HEXCOLOR(0xF9FAFD)
////蓝色
//#define COLOR_BLUE          HEXCOLOR(0x5A8DEE)
////浅蓝
//#define COLOR_BLUE_LIGHT    HEXCOLOR(0xE6EEFF)
////蓝色 高亮
//#define COLOR_BLUE_H        HEXCOLOR(0x719DF0)
////绿色
#define COLOR_GREEN         HEXCOLOR(0x44CD87)
////浅绿
#define COLOR_GREEN_LIGHT   HEXCOLOR(0xE1F7EC)
////红色
//#define COLOR_RED           HEXCOLOR(0xFF5B5C)
//浅红
#define COLOR_RED_LIGHT     HEXCOLOR(0xFFE9E9)
//橙色
#define COLOR_ORANGE        HEXCOLOR(0xFDAC41)
//浅橙
#define COLOR_ORANGE_LIGHT  HEXCOLOR(0xFFF0DE)
////粉蓝色
//#define COLOR_CYAN          HEXCOLOR(0x31D0DB)
////浅粉蓝
//#define COLOR_CYAN_LIGHT    HEXCOLOR(0xDEF7F9)
////紫色
//#define COLOR_PURPLE        HEXCOLOR(0x9487F6)
//////浅紫色
//#define COLOR_PURPLE_LIGHT  HEXCOLOR(0xF1F1FF)
////黄色
//#define COLOR_YELLOW        HEXCOLOR(0xFDAC41)
////浅黄色
//#define COLOR_YELLOW_LIGHT  HEXCOLOR(0xFFFAE2)


#pragma mark -- size

#define FIT_SCALE       (IS_IPHONE?(SCREEN_WIDTH/375.000000):1.5)

#define SCREEN_BOUNDS   [UIScreen mainScreen].bounds

#define SCREEN_SIZE     [[UIScreen mainScreen] bounds].size

#define SCREEN_WIDTH    [[UIScreen mainScreen] bounds].size.width

#define SCREEN_HEIGHT   [[UIScreen mainScreen] bounds].size.height

#define SCREEN_SCALE    [UIScreen mainScreen].scale

#define Size_1PX        1.0/[UIScreen mainScreen].scale

#define PX(x) x*FIT_SCALE


#pragma mark -- 适配 --

#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
//iPhonex系列
#define isIphoneX ({\
BOOL tmp = NO;\
if (@available(iOS 11.0, *)) {\
if ([UIApplication sharedApplication].delegate.window.safeAreaInsets.top > 20) {\
tmp = YES;\
}else{\
tmp = NO;\
}\
}else{\
tmp = NO;\
}\
tmp;\
})

#define IS_IOS_VERSION_11               (([[[UIDevice currentDevice]systemVersion]floatValue] >= 11.0)? (YES):(NO))

#define IS_IOS_VERSION_15               (([[[UIDevice currentDevice] systemVersion] floatValue] >= 15.0)? (YES):(NO))

#define IPHONE_TAB_BAR_HEIGHT           (isIphoneX ? 83 : 49)

#define IPHONE_NAVIGATION_BAR_HEIGHT    (isIphoneX ? (IS_IOS_VERSION_15?91:88) : 64)

#define IPHONE_BOTTOM_SAFEINSET         (isIphoneX ? 34 : 0)

#define IPHONE_TOP_SAFEINSET            (isIphoneX ? 44 : 20)


#pragma mark -- font

//系统字体
#define FONT(A)             [UIFont systemFontOfSize:A]
//数字字体
#define NUMBERFONT(A)       [UIFont numberFont:A]
//中粗
#define FONTMID(A)          [UIFont systemFontOfSize:A weight:UIFontWeightMedium]
//粗体
#define FONTBOLD(A)         [UIFont boldSystemFontOfSize:A]
//系统自适应大小
#define FONT_FIT(A)         [UIFont systemFontOfSize:A*FIT_SCALE]
//中粗自适应大小
#define FONTMID_FIT(A)      [UIFont systemFontOfSize:A*FIT_SCALE weight:UIFontWeightMedium]
//粗体自适应大小
#define FONTBOLD_FIT(A)     [UIFont boldSystemFontOfSize:A*FIT_SCALE]

#define NUMBERFONT_FIT(A)   [UIFont numberFont:A*FIT_SCALE]

#define MAPPDelegate ((AppDelegate*)[[UIApplication sharedApplication] delegate])

#endif /* Constants_h */
